import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    selectItem: ''
  },
  mutations: {
    saveSelect: (state, index) => {
      sessionStorage.selectItem = index
      state.selectItem = index
    }
  },
  getters: {
    getSelect: state => {
      if (!state.selectItem) {
        state.selectItem = sessionStorage.getItem('selectItem')
      }
      return state.selectItem
    }
  }
})